package com.example.myslidingmenu;

import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

public class AnimationCreator {
	
	public static Animation createFadeInAnimation() {
		return createAlphaAnimation(0, 1);
	}
	
	public static Animation createFadeInAnimation(float alpha) {
		return createAlphaAnimation(0, alpha);
	}
	
	public static Animation createFadeOutAnimation() {
		return createAlphaAnimation(1, 0);
	}
	
	public static Animation createFadeOutAnimation(float alpha) {
		return createAlphaAnimation(alpha, 0);
	}
	
	public static Animation createAlphaAnimation(float fromAlpha, float toAlpha) {
		AlphaAnimation anim = new AlphaAnimation(fromAlpha, toAlpha);
		
		return anim;
	}
	
	public static AnimationSet createSneakInOutXAnimation(
			float fromAlpha, float toAlpha,
			float fromXDelta, float toXDelta) {
		
		return createSneakInOutAnimation(fromAlpha, toAlpha, fromXDelta, toXDelta, 0, 0);
	}
	
	public static AnimationSet createSneakInOutYAnimation(
			float fromAlpha, float toAlpha,
			float fromYDelta, float toYDelta) {
		return createSneakInOutAnimation(fromAlpha, toAlpha, 0, 0, fromYDelta, toYDelta);
	}
	
	public static AnimationSet createSneakInOutAnimation(
			float fromAlpha, float toAlpha,
			float fromXDelta, float toXDelta,
			float fromYDelta, float toYDelta) {
		AnimationSet animationSet = new AnimationSet(true);
		
		Animation translateAnimation = createTranslateAnimation(
				fromXDelta, toXDelta, fromYDelta, toYDelta);
		
		Animation alphaAnimation = createAlphaAnimation(fromAlpha, toAlpha);
		
		animationSet.addAnimation(translateAnimation);
		animationSet.addAnimation(alphaAnimation);
		
		return animationSet;
	}
	
	public static Animation createTranslateAnimation(
			float fromXDelta, float toXDelta, float fromYDelta, float toYDelta) {
		TranslateAnimation anim = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
		
		return anim;
	}
	
	public static Animation createTranslateXAnimation(float fromXDelta, float toXDelta) {
		return createTranslateAnimation(fromXDelta, toXDelta, 0, 0);
	}
	
	public static Animation createTranslateYAnimation(float fromYDelta, float toYDelta) {
		return createTranslateAnimation(0, 0, fromYDelta, toYDelta);
	}
	
	public static Animation createScaleAnimation(
			float fromX, float toX, float fromY, float toY) {
		Animation anim = new ScaleAnimation(fromX, toX, fromY, toY,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
		
		return anim;
	}
	
	public static Animation createScaleXAnimation(float fromX, float toX) {
		return createScaleAnimation(fromX, toX, 0, 0);
	}
	
	public static Animation createScaleYAnimation(float fromY, float toY) {
		return createScaleAnimation(0, 0, fromY, toY);
	}
}
